package com.sren.boot.bootstrap;

import com.sren.boot.condition.ConditionalOnSystemProperty;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;

/**
 * @author: renshuai
 * @date: 2019/11/25 上午9:37
 * @Description:
 */

public class SystemPropertyConditionBootstrap {

	public static void main(String[] args) {
		ConfigurableApplicationContext context = new SpringApplicationBuilder(SystemPropertyConditionBootstrap.class)
				.web(WebApplicationType.NONE)
				.profiles("java8")
				.run(args);
		String helloWorld = context.getBean("helloWorld", String.class);
		System.out.println(helloWorld);
		context.close();
	}

	@Bean
	@ConditionalOnSystemProperty(name = "user.name", value = "sren")
	public String helloWorld() {
		return "hello sren";
	}


}
